imx: imx8qm: add domain off support
authorAnson Huang <[email protected]>
Thu, 12 Jul 2018 06:30:52 +0000 (14:30 +0800)
committerAnson Huang <[email protected]>
Thu, 12 Jul 2018 08:15:56 +0000 (16:15 +0800)
Add domain off support for Linux kernel's cpu
hot-plug feature, when there are cpu off request
from Linux kernel, TF-A will send command to
system controller to do CPU power gate accordingly,
tested on i.MX8QM MEK board.

Signed-off-by: Anson Huang <[email protected]>
plat/imx/common/imx8_topology.c
plat/imx/imx8qm/imx8qm_psci.c
plat/imx/imx8qx/include/platform_def.h

index bcb7d59f041fffb9db3f81a11c258c4f9bfc62b8..64145c4ca89744d9a0b5c79c86882a734967206e 100644 (file)
@@ -11,7 +11,8 @@
 const unsigned char imx_power_domain_tree_desc[] = {
        PWR_DOMAIN_AT_MAX_LVL,
        PLATFORM_CLUSTER_COUNT,
-       PLATFORM_CORE_COUNT,
+       PLATFORM_CLUSTER0_CORE_COUNT,
+       PLATFORM_CLUSTER1_CORE_COUNT,
 };
 
 const unsigned char *plat_get_power_domain_tree_desc(void)
index 217d9d969d3641357f21a191086244713fb50446..f7def4a117e3d34efb93c82b1b3fd362df8fdaf8 100644 (file)
@@ -85,6 +85,29 @@ void imx_pwr_domain_on_finish(const psci_power_state_t *target_state)
        plat_gic_cpuif_enable();
 }
 
+void imx_pwr_domain_off(const psci_power_state_t *target_state)
+{
+       u_register_t mpidr = read_mpidr_el1();
+       unsigned int cluster_id = MPIDR_AFFLVL1_VAL(mpidr);
+       unsigned int cpu_id = MPIDR_AFFLVL0_VAL(mpidr);
+
+       plat_gic_cpuif_disable();
+       if (cluster_id == 0) {
+               sc_pm_req_cpu_low_power_mode(ipc_handle, ap_core_index[cpu_id],
+                       SC_PM_PW_MODE_OFF, SC_PM_WAKE_SRC_NONE);
+               if (--a53_cpu_on_number == 0)
+                       cci_disable_snoop_dvm_reqs(0);
+       } else {
+               sc_pm_req_cpu_low_power_mode(ipc_handle,
+                       ap_core_index[cpu_id + 4],
+                       SC_PM_PW_MODE_OFF,
+                       SC_PM_WAKE_SRC_NONE);
+               if (--a72_cpu_on_number == 0)
+                       cci_disable_snoop_dvm_reqs(1);
+       }
+       tf_printf("turn off cluster:%d core:%d\n", cluster_id, cpu_id);
+}
+
 int imx_validate_ns_entrypoint(uintptr_t ns_entrypoint)
 {
        return PSCI_E_SUCCESS;
@@ -93,6 +116,7 @@ int imx_validate_ns_entrypoint(uintptr_t ns_entrypoint)
 static const plat_psci_ops_t imx_plat_psci_ops = {
        .pwr_domain_on = imx_pwr_domain_on,
        .pwr_domain_on_finish = imx_pwr_domain_on_finish,
+       .pwr_domain_off = imx_pwr_domain_off,
        .validate_ns_entrypoint = imx_validate_ns_entrypoint,
        .system_off = imx_system_off,
        .system_reset = imx_system_reset,
index 2cd140097db141777b5fd9d9b9e385c201dd8613..8c86174695104ff974f3eb970d215bd3f9a857cf 100644 (file)
@@ -17,6 +17,8 @@
 #define PLATFORM_MAX_CPU_PER_CLUSTER   4
 #define PLATFORM_CLUSTER_COUNT         1
 #define PLATFORM_CORE_COUNT            4
+#define PLATFORM_CLUSTER0_CORE_COUNT   4
+#define PLATFORM_CLUSTER1_CORE_COUNT   0
 
 #define PWR_DOMAIN_AT_MAX_LVL           1
 #define PLAT_MAX_PWR_LVL                2